<?php
global $_GPC, $_W;
$ip = $_SERVER['REMOTE_ADDR'];
$apikey = $_GPC['apikey'];
$is_apikey = pdo_get("asterye_huaxcx_iptime", array("apikey" => $apikey));
if(!$is_apikey){
	exit(json_encode(array('code' => 501, 'msg' => 'apikey错误')));
}
$iptime = pdo_get("asterye_huaxcx_iptime", array("ip" => $ip));
if($iptime){
	if($iptime['lasttime'] >= time()-120){
		exit(json_encode(array('code' => 501, 'msg' => '接口现在频率2分钟')));
	}else{
		$res=pdo_update('asterye_huaxcx_iptime', array('lasttime' => time()), array("ip" => $ip));
	}
}else{
	$res=pdo_insert('asterye_huaxcx_iptime', array('lasttime' => time(),"ip" => $ip));
}
$lastid=intval($_GPC['lastid']);
if (!$lastid) {
	$lastid = 0;
}
$list = pdo_fetchall("SELECT * FROM " . tablename("asterye_huaxcx_groupchat_sync") . " where id > ".$lastid." ORDER BY id ASC LIMIT 0,10");
exit(json_encode(array('code' => 100, 'data' => $list)));